﻿using Business;
using Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BookManageSys.User
{
    public partial class ForgetPassword : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void BtnRegister_Click(object sender, EventArgs e)
        {
            UsersEntity ue = new UsersEntity();
            ue.Username = TxtUsername.Text;
            ue.Password = TxtPassword.Text;
            ue.Telephone = TxtTelephone.Text;

            try
            {
                UsersBusiness ub = new UsersBusiness();
                object obj = ub.CheckExist(ue);

                if (obj != null)
                {
                    int res = ub.FrogetPassword(ue);
                    if (res > 0)
                    {
                        Response.Write("<script>alert('密码修改成功！'),location.href='../UserLogin.aspx'</script>");
                    }
                    else
                    {
                        Response.Write("<script>alert('注册失败！')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('账号或电话不正确')<script>");
                }
            }
            catch
            {
                Response.Write("<script>alert('账号或电话不正确')<script>");
            }
        }
    }
}